package com.ruoyi.app.controller;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.app.domain.ShopProfession;
import com.ruoyi.app.service.IShopProfessionService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户信息Controller
 * 
 * @author ruoyi
 * @date 2024-07-07
 */
@RestController
@RequestMapping("/shop/profession")
public class ShopProfessionController extends BaseController
{
    @Autowired
    private IShopProfessionService shopProfessionService;

    /**
     * 查询用户信息列表
     */
    @PreAuthorize("@ss.hasPermi('shop:profession:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopProfession shopProfession)
    {
        startPage();
        List<ShopProfession> list = shopProfessionService.selectShopProfessionList(shopProfession);
        return getDataTable(list);
    }

    /**
     * 导出用户信息列表
     */
    @PreAuthorize("@ss.hasPermi('shop:profession:export')")
    @Log(title = "用户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopProfession shopProfession)
    {
        List<ShopProfession> list = shopProfessionService.selectShopProfessionList(shopProfession);
        ExcelUtil<ShopProfession> util = new ExcelUtil<ShopProfession>(ShopProfession.class);
        util.exportExcel(response, list, "用户信息数据");
    }

    /**
     * 获取用户信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:profession:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(shopProfessionService.selectShopProfessionById(id));
    }

    /**
     * 新增用户信息
     */
    @PreAuthorize("@ss.hasPermi('shop:profession:add')")
    @Log(title = "用户信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ShopProfession shopProfession)
    {
        return toAjax(shopProfessionService.save(shopProfession));
    }

    /**
     * 修改用户信息
     */
    @PreAuthorize("@ss.hasPermi('shop:profession:edit')")
    @Log(title = "用户信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ShopProfession shopProfession)
    {
        return toAjax(shopProfessionService.updateById(shopProfession));
    }

    /**
     * 删除用户信息
     */
    @PreAuthorize("@ss.hasPermi('shop:profession:remove')")
    @Log(title = "用户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        List<String> objects = Arrays.asList(ids);
        return toAjax(shopProfessionService.removeByIds(objects));
    }
}
